<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8">
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <!--[if lt IE 9]>
    <script type="text/javascript" src="../../../lib/html5shiv.js?rev=@@hash"></script>
    <script type="text/javascript" src="../../../lib/respond.min.js?rev=@@hash"></script>
    <![endif]-->
    <link rel="stylesheet" type="text/css" href="../../../static/h-ui/css/H-ui.min.css" />
    <link rel="stylesheet" type="text/css" href="../../../static/h-ui.admin/css/H-ui.admin.css" />
    <link rel="stylesheet" type="text/css" href="../../../lib/Hui-iconfont/1.0.8/iconfont.css" />
    <link rel="stylesheet" type="text/css" href="../../../static/h-ui.admin/skin/default/skin.css" id="skin" />
    <link rel="stylesheet" type="text/css" href="../../../static/h-ui.admin/css/style.css" />
    <link rel="stylesheet" type="text/css" href="../../../ht-css/style-q.css" />
    <link rel="stylesheet" type="text/css" href="../../../ht-css/Project.css" />
    <!--[if IE 6]>
    <script type="text/javascript" src="../../../lib/DD_belatedPNG_0.0.8a-min.js?rev=@@hash"></script>
    <script>DD_belatedPNG.fix('*');</script>
    <![endif]-->
    <title>编辑详情</title>
</head>
<body>
<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span>对接平台管理<span
        class="c-gray en">&gt;</span>渠道管理<span
        class="c-gray en">&gt;</span>编辑详情<a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px"
                                            href="javascript:location.replace(location.href);" title="刷新"><i
        class="Hui-iconfont">&#xe68f;</i></a></nav>
<article class="page-container">
    <form class="ml-20 mr-20">
    <div class="bg-1 bk-gray pb-10">

        <div class="lh-30 mb-10">
            <table class="table_li mb-10 table">
                <thead class="text-l">
                <tr>
                    <td class="col-3-1 text-l">
                        <div class="row ml-10">
                            <label class="form-label f-l w-100 text-r lh-26">渠&nbsp;道&nbsp;I&nbsp;D：</label>
                            <div class="formControls ml-10 lh-26" id="customerId"></div>
                        </div>
                    </td>
                    <td class="col-3-1 text-l">
                        <div class="row ml-10">
                            <label class="form-label f-l w-100 text-r lh-26"><span class="c-red pr-5 pl-15">*</span>渠道名称：</label>
                            <div class="formControls f-l">
                                <input type="text" style="width:120%" datatype="*" nullmsg="录入必填信息！" errormsg="录入必填信息" class="input-text radius" name="customerName" id="customerName"
                                       placeholder="输入渠道名称" maxlength="64"><span id="messageBallot" class="tip"></span>
                            </div>
                        </div>
                    </td>
                    <td class="col-3-1 text-l">
                        <div class="row ml-10">
                            <label class="form-label f-l w-100 text-r lh-26"><span class="c-red pr-5 pl-15">*</span>客户归属：</label>
                            <div class="formControls f-l">
                                <input type="text" style="width:300px;" class="input-text radius w-150 ml-10" onclick="belongFunction()" id="organization_name"  placeholder="请输入客户归属" autocomplete="off" readonly>
                                <ul class="relation radius guanlian" id="tuan" style="width:93%;z-index: 1">
                                    <li>无数据</li>
                                </ul>
                            </div>
                        </div>
                    </td>
                </tr>
                <tr>
                    <td class="col-3-1 text-l">
                        <div class="row ml-10">
                            <label class="form-label f-l w-100 text-r lh-26"><span class="c-red pr-5">*</span>渠道对接模式：</label>
                            <div class="formControls ml-10 lh-26" id="interfaceType"></div>
                            <!--<div class="formControls col-xs-7">
                                <select class="select radius f-l" size="1" style="height: 30px;" id="interfaceType">
                                    <option value="1">我司标准，推送</option>
                                    <option value="2">对方标准，拉取</option>
                                    <option value="3">我司标准，拉取</option>
                                </select>
                            </div>-->
                        </div>
                    </td>
                    <td class="col-3-1 text-l">
                        <div class="row ml-10">
                            <label class="form-label f-l w-100 text-r lh-26"><span class="c-red pr-5">*</span>渠道状态：</label>
                            <div class="formControls col-xs-7">

                                <select class="select radius f-l" size="1" style="height: 30px;" id="customerStatus">
                                    <option value="10">启用</option>
                                    <option value="20">禁用</option>
                                </select>
                            </div>
                        </div>
                    </td>
                    <td class="col-3-1 text-l">
                        <div class="row ml-10">
                            <label class="form-label f-l w-100 text-r lh-26"><span class="c-red pr-5">*</span>是否匹配项目：</label>
                            <div class="formControls col-xs-7">
                                <select class="select radius f-l" size="1" style="height: 30px;" id="isOrNotMatch">
                                    <option value="1">是</option>
                                    <option value="0">否</option>
                                </select>
                            </div>
                        </div>
                    </td>
                </tr>
                </thead>
            </table>
        </div>
        <div class="line"></div>

        <div class="pd-20">
            <div class="clearfix mb-15">
                <label class="f-l pt-5"><span class="c-red pr-5 pl-15">*</span>渠道平台描述：</label>
                <div class="formControls col-sm-5">
                    <textarea class="textarea" id="customerPlatform" title="" maxlength="200"  onkeyup="this.value=this.value.replace(/\s+/g,'')"></textarea></div><!--不能输入空格-->
            </div>
        </div>
        <div class="pd-20">
            <div class="clearfix mb-15">
                <label class="f-l pt-5">对接情况描述：</label>
                <div class="formControls col-sm-5">
                    <textarea class="textarea" id="description" title="" maxlength="500"  onkeyup="this.value=this.value.replace(/\s+/g,'')"></textarea></div>
            </div>
        </div>
        <div class="text-c mb-10 ">
            <button class="btn radius size-S" onclick="colse()">取消</button>
            <a class="btn btn-secondary radius size-S ml-10" onclick="channeladd()">保存</a>
        </div>


    </div>
</form>
</article>
<!--_footer 作为公共模版分离出去-->
<script type="text/javascript" src="../../../lib/jquery/1.9.1/jquery.min.js?rev=@@hash"></script>
<script type="text/javascript" src="../../../lib/layer/2.4/layer.js?rev=@@hash"></script>
<script type="text/javascript" src="../../../static/h-ui/js/H-ui.min.js?rev=@@hash"></script>
<script type="text/javascript" src="../../../static/h-ui.admin/js/H-ui.admin.js?rev=@@hash"></script> <!--/_footer 作为公共模版分离出去-->
<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="../../../lib/My97DatePicker/4.8/WdatePicker.js?rev=@@hash"></script>
<!--表单验证-->
<script type="text/javascript" src="../../../lib/jquery.validation/1.14.0/jquery.validate.js?rev=@@hash"></script>
<script type="text/javascript" src="../../../lib/jquery.validation/1.14.0/validate-methods.js?rev=@@hash"></script>
<script type="text/javascript" src="../../../lib/jquery.validation/1.14.0/messages_zh.js?rev=@@hash"></script>
<script type="text/javascript" src="../../../lib/datatables/1.10.0/jquery.dataTables.min.js?rev=@@hash"></script>
<script src="../../../ht-js/frame/doT.min.js?rev=@@hash"></script>
<script type="text/javascript" src="../../../lib/laypage/1.2/laypage.js?rev=@@hash"></script>
<!--引入分页-->
<link rel="stylesheet" href="../../../ht-css/contract/paginationnn.css">
<script src="../../../lib/pagination/jquery.pagination.js?rev=@@hash"></script>
<script src="../../../ht-js/public.js?rev=@@hash"></script>
<!--验证token-->
<script src="../../../ht-js/verifyToken.js?rev=@@hash"></script>
<!--权限控制-->
<script type="text/javascript" src="../../../ht-js/power.js?rev=@@hash"></script>
<script type="text/javascript" src="../../../ht-js/warehouse.js?rev=@@hash"></script>
<script>
    $(function(){
        var detail = JSON.parse(sessionStorage.getItem("detail"));
        $("#customerId").html(detail.customerId);
        $("#customerName").val(detail.customerName);
        $("#organization_name").val(detail.customerBelong);
        if(detail.platformType==1){
            $("#interfaceType").html("我司标准，推送");
        }else if(detail.platformType==2){
            $("#interfaceType").html("对方标准，拉取");
        }else if(detail.platformType==3){
            $("#interfaceType").html("我司标准，拉取");
        }
        $("#customerStatus").val(detail.state);
        $("#customerPlatform").val(detail.customerPlat);
        $("#description").val(detail.description);

        $('#isOrNotMatch').val(detail.isMatchingItems);
        console.log(detail,'jjj')
        sessionStorage.removeItem("detail");

        console.log(detail.state)
        //Customerquery()
        //ascription()
    });
    //运营经理关联
    function belongFunction(){
        //销售经理

        var manager=$("#organization_name").val();
        var user_data = {
            "pageNum":1,

            "pageSize":20,

        }
        var succCallBack = function (data, status, response) {
            console.log(data)
            if(data.errorCode=="0"){
                var jsonObj =data.group;
                if(jsonObj==""){
                    $("#tuan").html("<li>无数据</li> ");
                }else {
                    console.log(jsonObj)

                    var optionstring = "";
                    for (var  i= 0; i < jsonObj.length; i++) {
                        optionstring += "<li onclick='relation("+ jsonObj[i].id+",\""+jsonObj[i].organization_name+"\")' data-align=\"" + jsonObj[i].id + "\" > " + jsonObj[i].organization_name + "</li>";
                    }
                    $("#tuan").html(optionstring);
                    console.log(jsonObj)
                }
            }else{
                $("#tuan").html("<li>无数据</li> ");
            }
        }
        /*root.member.getGroup*/
        web.doAjax(root.member.getGroup,'post',user_data, succCallBack);

    }
    //取光标
    $("#organization_name").focus(function () {
        $("#tuan").show()
    });
    $(document).bind("click",function(e){
        //id为menu的是菜单，id为open的是打开菜单的按钮
        if($(e.target).closest("#tuan").length == 0 && $(e.target).closest("#organization_name").length == 0){
            //点击id为menu之外且id不是不是open，则触发
            $("#tuan").hide()
        }
    })
    function relation(id,ce) {
        $("#organization_name").val(ce).text(id)
        $("#tuan").hide()
        console.log($("#organization_name").text())
    }
//channelDetails()
function channelDetails() {
    $.ajax({
        url:root.dockingplatform.queryByCustomerCode,
        cache: false,  //禁用缓存
        type: "POST",
        dataType:'json',
        contentType: "application/json",
        data: JSON.stringify({
            "customerCode":sessionStorage.getItem("customerCode"),
        }),
        success: function (data) {
             console.log(data);
            $("#customerId").html(data.data.customerId);
            $("#customerName").html(data.data.customerName);
            $("#customerBelong").html(data.data.customerBelong);
            $("#interfaceType").html(data.data.interfaceType);
            $("#customerStatus").val(data.data.customerStatus);
            $("#customerPlatform").val(data.data.customerPlatform);
            $("#description").val(data.data.description);
        },
        error: function () {
            $.Huimodalalert('失败！',2000);
        }
    });
}

function channeladd() {
    if($("#customerPlatform").val()==""){
        console.log($("#customerPlatform").val())
        $.Huimodalalert('录入必填信息',2000);
        return false;
    }
    if($("#customerName").val()==""){
        console.log($("#customerPlatform").val())
        $.Huimodalalert('录入必填信息',2000);
        return false;
    }
    if($("#organization_name").val()==""){
        console.log($("#customerPlatform").val())
        $.Huimodalalert('录入必填信息',2000);
        return false;
    }
   /* if($("#description").val()==""){
        $.Huimodalalert('请填写对接情况描述',2000);
        return false;
    }*/
    $.ajax({
        url:root.dockingplatform.updateForView,
        cache: false,  //禁用缓存
        type: "POST",
        dataType:'json',
        contentType: "application/json",
        data: JSON.stringify({
            "customerId":$("#customerId").html(),
            "customerName":$("#customerName").val(),
            //"interfaceType":$("#interfaceType").val(),
            "customerStatus":$("#customerStatus").val(),
            "customerPlatform":$("#customerPlatform").val(),
            "description":$("#description").val(),
            "customerBelong":$("#organization_name").val(),
            isMatchingItems:$('#isOrNotMatch').find('option:selected').val(),//是都匹配标识
            //是否匹配项目
        }),
        success: function (data) {
            if(data.errorCode==0){
                layer.msg('修改成功', {
                    icon: 6,
                    time: 1000
                }, function() {
                    var index = parent.location.reload();
                    parent.layer.close(index);
                });
            }else{
                $.Huimodalalert(data.msg,2000);
            }

        },
        error: function (data) {
            $.Huimodalalert(data.msg,2000);
        }
    });
}
//取消
    function colse() {
        parent.layer.closeAll();
    }
</script>
</body>
</html>